// LeftView.h : interface of the CLeftView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_LEFTVIEW_H__2BAC6456_8072_4FA2_A7FD_7A1091EB0946__INCLUDED_)
#define AFX_LEFTVIEW_H__2BAC6456_8072_4FA2_A7FD_7A1091EB0946__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "SpriteDoc.h"

class CLeftView : public CTreeView
{
protected: // create from serialization only
	CLeftView();
	DECLARE_DYNCREATE(CLeftView)

// Attributes
public:
	CSpriteDoc* GetDocument();

	typedef CSpriteDoc::TDATA TDATA;
	typedef CSpriteDoc::FCLIP FCLIP;
	typedef CSpriteDoc::FRAME FRAME;
	typedef CSpriteDoc::ACTION ACTION;
	typedef CSpriteDoc::SPRITE SPRITE;
	typedef CSpriteDoc::IMAGE IMAGE;

public:
	void OnDelete();
	BOOL	m_bDeleteSuccess;

// Operations
public:

	void HitSelect(int x, int y);
	void OnSelect(HTREEITEM hSelect);

	void OnAddFclip(LPCTSTR p);

	void OnSetFclipUp();
	void OnSetFclipDn();

	void OnNewSprite();
	void OnNewAction();
	void OnNewFrame();

	BOOL DeleteFclip(HTREEITEM hFclip);
	BOOL DeleteFrame(HTREEITEM hFrame);
	BOOL DeleteAction(HTREEITEM hAction);
	BOOL DeleteSprite(HTREEITEM hSprite);

protected:
	HTREEITEM GetFclipItem(HTREEITEM hSelect);
	HTREEITEM GetFrameItem(HTREEITEM hSelect);
	HTREEITEM GetActionItem(HTREEITEM hSelect);
	HTREEITEM GetSpriteItem(HTREEITEM hSelect);

	HTREEITEM GetSelectFclip();

	BOOL	m_bPlay;
	UINT	m_nTimer;

	HTREEITEM m_hCutItem;
	HTREEITEM m_hCopyItem;

	HTREEITEM m_hActFrame; // for Animation

	void CopyFrame(HTREEITEM hSrc, HTREEITEM hTar);
	void CloneFrame(HTREEITEM hSrc, HTREEITEM hTar);

	void OnMoveFrame(HTREEITEM& hFrame, int nMove);

	void SwapFclip(HTREEITEM hFclip1, HTREEITEM hFclip2);

	void CopyFclip(HTREEITEM hSrc, HTREEITEM hTar);

	void CopyAction(HTREEITEM hSrc, HTREEITEM hTar);
	void CopySprite(HTREEITEM hSrc, HTREEITEM hTar);

protected:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CLeftView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	virtual void OnInitialUpdate(); // called first time after construct
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CLeftView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CLeftView)
	afx_msg void OnSelChanged(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnMakeDn();
	afx_msg void OnMakeUp();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnDestroy();
	afx_msg void OnBeginLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnAutoPlay();
	afx_msg void OnUpdateAutoPlay(CCmdUI* pCmdUI);
	afx_msg void OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEditCopy();
	afx_msg void OnEditPaste();
	afx_msg void OnEditCut();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in LeftView.cpp
inline CSpriteDoc* CLeftView::GetDocument()
   { return (CSpriteDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_LEFTVIEW_H__2BAC6456_8072_4FA2_A7FD_7A1091EB0946__INCLUDED_)
